/**
 * Created by Administrator on 2022/8/31.
 */
class Student {
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public void fun() {
        System.out.println(name+age);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object obj) {
        Student stu = (Student)obj;
        if(this.name.equals(stu.name) && this.age == stu.age) {
            return true;
        } else {
            return false;
        }
    }
}
public class Test5 {
    public static void Tmp(Object object) {
        System.out.println(object);//println默认会调用toString
    }
    public static void main(String[] args) {
        Student student = new Student("小明",1);
        //Tmp(student);
        //System.out.println(student.toString());
        Student student2 = new Student("小明",1);
        if(student.equals(student2)){
            System.out.println("==");
        } else {
            System.out.println("!=");
        }
    }
}
